//
//  EmojiKeyBoardCell.swift
//  EmojiKeyBoard
//
//  Created by macs on 15/11/20.
//  Copyright © 2015年 BlackTail. All rights reserved.
//

import UIKit

class EmojiKeyBoardCell: UICollectionViewCell {
    
    var emoji : Emoji? {
        
        didSet{
            
               btn.setBackgroundImage(UIImage(contentsOfFile: emoji?.imagePath ?? ""), forState: .Normal)
                btn.setTitle(emoji!.codeString ?? "", forState: .Normal)
            if emoji?.isRemove == true {
                
                btn.setBackgroundImage(UIImage(named: "compose_emotion_delete"), forState: .Normal)
            }
        }
    }
    //3.重写构造方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //2.添加子控件,设置约束
    private func setupUI() {
        contentView.addSubview(btn)
        btn.frame = CGRectInset(bounds, 4, 4)
        btn.backgroundColor = UIColor.whiteColor()
        btn.titleLabel?.font = UIFont.systemFontOfSize(32)
        btn.userInteractionEnabled = false
    }
    //1.懒加载控件
    private lazy var btn  = UIButton()
}
